package com.yao2san.simdif.enums;

import lombok.Getter;

/**
 * 驱动
 *
 * @author wxg
 */
public enum Drivers {
    /**
     * mysql
     */
    MYSQL("mysql", "mysql", "drivers/mysql-connector-java-5.1.47.jar", "com.mysql.jdbc.Driver"),
    /**
     * oracle
     */
    ORACLE("oracle", "oracle", "drivers/ojdbc8-23.2.0.0.jar", "oracle.jdbc.driver.OracleDriver"),
    /**
     * pgsql
     */
    PGSQL("pgsql", "pgsql", "drivers/postgresql-42.6.0.jar", "org.postgresql.Driver"),
    /**
     * sqlserver
     */
    SQLSERVER("sqlserver", "sqlserver", "drivers/mssql-jdbc-12.2.0.jre8.jar", "com.microsoft.sqlserver.jdbc.SQLServerDriver"),
    /**
     * tidb
     */
    TIDB("tidb", "tidb", "drivers/mysql-connector-java-5.1.47.jar", "com.mysql.jdbc.Driver"),
    /**
     * h2
     */
    H2("h2", "h2", "drivers/h2-2.1.214.jar", "org.h2.Driver"),
    ;

    @Getter
    private final String type;
    @Getter
    private final String name;
    @Getter
    private final String driver;
    @Getter
    private final String driverClassName;

    Drivers(String type, String name, String driver, String driverClassName) {
        this.type = type;
        this.name = name;
        this.driver = driver;
        this.driverClassName = driverClassName;
    }

    public static Drivers of(String type) {
        for (Drivers value : Drivers.values()) {
            if (value.type.equals(type)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Not supported driver: " + type);
    }
}
